symbolic calculation in Python